package com.yuwei.user.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.yuwei.user.R
import com.yuwei.user.databinding.LayoutHelpItemBinding
import com.yuwei.user.entity.HelpItemEntity

class HelpAdapter(val data:List<HelpItemEntity>):RecyclerView.Adapter<HelpAdapter.HelpViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HelpViewHolder {
        val itemDataBinding=
            LayoutHelpItemBinding.inflate(LayoutInflater.from(parent.context),parent,false)
        return HelpViewHolder(itemDataBinding)
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: HelpViewHolder, position: Int) {
        val itemData=data[position]
        holder.itemView.findViewById<TextView>(R.id.tv_status).setText(itemData.title)
        holder.itemView.findViewById<TextView>(R.id.tv_desc).setText(itemData.desc)
        if (holder.itemView.findViewById<TextView>(R.id.tv_desc).text.equals("")){
            holder.itemView.findViewById<TextView>(R.id.tv_desc).visibility=View.GONE
        }
    }


    class HelpViewHolder(val itemView:LayoutHelpItemBinding):RecyclerView.ViewHolder(itemView.root)
}